home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!rpl
- From: rpl@netcom.com (Robert Laudati)
- Subject: Struct as default arg?
- Message-ID: <rplDLrDFr.35K@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- X-Newsreader: TIN [version 1.2 PL1]
- Date: Thu, 25 Jan 1996 22:35:51 GMT
- Sender: rpl@netcom23.netcom.com
-
- I would like to use a structure as a default args as follows:
-
- file.h
- ======
-
- typedef struct { double x; double y; } Point;
-
- int Write( int n, char *s, Point p={0.0,0.0} );
-
-
- prog.cc
- =======
-
- status = Write( 34, "String" ); // Output: 34, String, 0.0, 0.0
- .
- .
- .
- Point pnt = {110.0, 34.0 };
- status = Write( 102, "Label", pnt ); // Output: 102, Label, 110.0, 34.0
-
- I get an error compiling stating:
-
- argument list may not have an initializer list
- *** Error code 1
-
- Is there any way to provide default arguments for a struc in a function?
- (There are no classes involved in this example). Thanks,
-
- Rob
- --
- .........................................................
- . Robert P. Laudati rob_laudati@trimble.com .
- . Trimble Navigation Ltd. rpl@netcom.com .
- . P.O. Box 3642 (408) 481-8292 voice .
- . Sunnyvale, CA 94088 (408) 481-8730 fax .
- . .
- . These views are not necessarily those of Trimble. .
- .........................................................
-